package com.edu.internship.busi.controller;


import com.edu.internship.config.redis.RedisUtil;
import com.edu.internship.config.redis.RedisUtilTotal;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;
import java.util.Set;

@RequestMapping("/redis")
@RestController
@Api(tags = {"redis缓冲"})
@Slf4j

public class RedisController {

    @Resource
    private RedisUtilTotal redisUtilTotal;
    @Resource
    private RedisUtil redisUtil;

    @RequestMapping
    @ApiOperation(value = "redis-set",notes = "redis-set")
    public boolean set(String key,String value){
        return redisUtil.set(key,value,100 * 100 * 60);
    }


    @GetMapping("/get")
    @ApiOperation(value = "redis-get",notes = "redis-get")
    public Object get(String key){
        return redisUtil.get(key);
    }

    @GetMapping("/test")
    @ApiOperation(value = "其他测试",notes = "其他测试")
    public Map<String, Object> require(String key){
        return redisUtil.keys(key);
    }

    @GetMapping("/1test")
    @ApiOperation(value = "其他测试",notes = "其他测试")
    public boolean requires(String key){
        return redisUtil.deleteKeys(key);
    }
}
